﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Add</title>
    <link rel="stylesheet" href="~/lib/layui/css/layui.css" media="all">
</head>
<body>
    <div>
        <form class="layui-form" action="">

            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="ControllerName" id="ControllerName" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="text" name="ActionName" id="ActionName" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo" id="send">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/lib/layui/layui.js" charset="utf-8"></script>
    <script>

        layui.use('form', function () {
            var form = layui.form;
            var $ = layui.$;
            var layer = layui.layer;
            //监听提交
            form.on('submit(formDemo)', function (data) {
                var qw = $("#ControllerName").val();
                var ed = $("#ActionName").val();
                $.ajax({
                    type: "get",
                    contentType: "application/json",
                    url: "/api/yonghu/adds",
                    data: { "name": qw, "pad": ed },
                    success: function (res) {
                        if (res.cood == 200) {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                            window.parent.location.reload();
                            layer.msg("添加成功")

                        } else {
                            layer.msg("添加失败")
                        }

                    }
                })
                return false;
            });
        });
    </script>
</body>
</html>
